Skip to content

Comments

Feat: cache workflow file#382

Merged
S1ro1 merged 1 commit intomainfrom
cache-workflow-file
Dec 18, 2025
Merged

Feat: cache workflow file#382
S1ro1 merged 1 commit intomainfrom
cache-workflow-file

Conversation

@S1ro1
Copy link
Member

@S1ro1 S1ro1 commented Dec 17, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 17, 2025 02:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a caching mechanism for GitHub workflow file lookups to reduce redundant API calls when triggering workflows. The implementation adds a module-level cache dictionary and a new get_workflow() method that checks the cache before fetching from the GitHub API.

Key changes:

  • Introduces _WORKFLOW_FILE_CACHE module-level dictionary to store Workflow objects
  • Adds get_workflow() async method to retrieve cached workflows or fetch from GitHub
  • Updates trigger() method to use the new caching mechanism instead of direct API calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

logger.info(f"Returning cached workflow {self.workflow_file}")
return _WORKFLOW_FILE_CACHE[self.workflow_file]
logger.info(f"Fetching workflow {self.workflow_file} from GitHub")
workflow = self.repo.get_workflow(self.workflow_file)
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_workflow method is declared as async but doesn't perform any await operations. Line 222 calls self.repo.get_workflow synchronously, which is a blocking network I/O operation that was previously wrapped with asyncio.to_thread at line 246. Removing the asyncio.to_thread wrapper without making the method properly async means this now blocks the event loop. Either add back the asyncio.to_thread wrapper, or change this to a synchronous method if blocking is acceptable.

Suggested change
workflow = self.repo.get_workflow(self.workflow_file)
workflow = await asyncio.to_thread(self.repo.get_workflow, self.workflow_file)

Copilot uses AI. Check for mistakes.
@S1ro1 S1ro1 merged commit 161fc8d into main Dec 18, 2025
9 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant